﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using DatabaseHelper;
using System.IO;
using SDK10kWrapper;
using System.Configuration;
using RS232;
using UI.Online.SubForms;

namespace UI.Online
{
    public partial class frmOnlineUI2
    {
        private void DisableComboboxes()
        {
            cbbProject.Enabled = false;
            cbbPipeline.Enabled = false;
        }
                
        private void EnableComboboxes()
        {
            cbbProject.Enabled = true;
            cbbPipeline.Enabled = true;
        }
                    
        private void DisableEventButtons()
        {
            btnAdd.Enabled = false;
            btnDelete.Enabled = false;
            btnSave.Enabled = false;
        }

        private void EnableEventButtons()
        {
            btnAdd.Enabled = true;
            btnDelete.Enabled = true;
            btnSave.Enabled = true;
        }

        private void DisableRecordButtons()
        {
            btnStartRecord.Enabled = false;
            btnStopRecord.Enabled = true;
        }

        private void EnableRecordButtons()
        {
            btnStartRecord.Enabled = true;
            btnStopRecord.Enabled = false;
        }

        private void DisableMenuItems()
        {
            List<ToolStripMenuItem> myItems = GetItems(mnuMain);
            foreach (var item in myItems)
            {
                item.Enabled = false;
            }
            mnuFile.Enabled = true;
            mnuSettings.Enabled = true;
            mnuHelp.Enabled = true;
        }

        private void EnableMenuItems()
        {
            List<ToolStripMenuItem> myItems = GetItems(mnuMain);
            foreach (var item in myItems)
            {
                item.Enabled = true;
            }
        }

        private static List<ToolStripMenuItem> GetItems(MenuStrip menuStrip)
        {
            List<ToolStripMenuItem> myItems = new List<ToolStripMenuItem>();
            foreach (ToolStripMenuItem i in menuStrip.Items)
            {
                GetMenuItems(i, myItems);
            }
            return myItems;
        }

        private static void GetMenuItems(ToolStripMenuItem item, List<ToolStripMenuItem> items)
        {
            items.Add(item);
            foreach (ToolStripItem i in item.DropDownItems)
            {
                if (i is ToolStripMenuItem)
                {
                    GetMenuItems((ToolStripMenuItem)i, items);
                }
            }
        }
        private string GetRecordFolder()
        {
            string PipelineFolder = (currProjectLocation + "\\" + currPipelineName + "\\");

            if (System.IO.Directory.Exists(currProjectLocation))
            {
                System.IO.Directory.CreateDirectory(currProjectLocation);
            }
            if (System.IO.Directory.Exists(PipelineFolder))
            {
                System.IO.Directory.CreateDirectory(PipelineFolder);
            }
            return PipelineFolder;
        }
    }
}
